import '@/utils/globals'

import Vue from 'vue'

import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import locale from 'element-ui/lib/locale/lang/zh-CN'

import App from './App'
import router from './router'
import store from './store'

import NProgress from 'nprogress'

NProgress.configure({ showSpinner: false })

import { library } from '@fortawesome/fontawesome-svg-core'
import { fas } from '@fortawesome/free-solid-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'

library.add(fas)

Vue.component('font-awesome-icon', FontAwesomeIcon)

import '@/permission'

// 注册按照后台配置来生成页面时要用的组件
import '@/builder'

// 注册其他组件和修改element组件
import '@/components'

Vue.use(ElementUI, { locale, size: 'medium' })

Vue.config.productionTip = false

const vm = new Vue({
  el: '#app',
  router,
  store,
  components: { App },
  template: '<App/>',
})

vm.$router.reload = () => {
  vm.$router.push({
    path: vm.$route.path,
    query: Object.assign({}, vm.$route.query, { _refresh: Date.now() }),
  })
}
